import React, { useState, useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import './login.scss'

export default function Login() {
    useEffect(() => {
        setPhone(localStorage.getItem('user'))
    })

    const [count, setCount] = useState(3)
    const navigate = useNavigate()
    const [phone, setPhone] = useState('')

    let time = setInterval(() => {
        setCount(count - 1)
    }, 1000);


    // if (count === 0) {
    //     clearInterval(time)
    //     if (phone) {
    //         navigate('/reallogin')
    //     } else {
    //         navigate('/app/home')
    //     }
    // }

    // let login = () => {
    //     if (phone) {
    //         navigate('/reallogin')
    //     } else {
    //         navigate('/app/home')
    //     }
    // }

    if (count === 0) {
        clearInterval(time)
        navigate('/app/home')
    }

    let login = () => {
        navigate('/app/home')
    }


    return (
        <div className='box1'>
            <button onClick={login}>跳过{count}</button>
        </div>
    )
}
